package com.uzai.console.cashier.fallback;

import com.uzai.common.dto.base.UzaiRespVo;
import com.uzai.console.cashier.CashierWxPayClient;
import com.uzai.console.cashier.dto.WxOrderQueryDto;
import com.uzai.console.cashier.param.CashierWechatPayParam;
import com.uzai.console.cashier.param.CashierWechatPayQueryParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author mingyang.chen create in 2023/11/9 11:48
 */
@Component
@Slf4j
public class CashierWxPayClientFallBack implements FallbackFactory<CashierWxPayClient> {
    @Override
    public CashierWxPayClient create(Throwable throwable) {
        log.error(throwable.getMessage(), throwable);
        return new CashierWxPayClient() {
            @Override
            public UzaiRespVo<?> placeOrder(CashierWechatPayParam cashierWechatPayParam) {
                return UzaiRespVo.fail("微信JSAPI下单失败");
            }

            @Override
            public UzaiRespVo<WxOrderQueryDto> queryOrder(CashierWechatPayQueryParam wechatPayDto) {
                return UzaiRespVo.fail("微信JSAPI查询订单失败");
            }

            @Override
            public UzaiRespVo<Boolean> closeOrder(CashierWechatPayQueryParam wechatPayDto) {
                return UzaiRespVo.fail("微信JSAPI关闭订单失败");
            }

            @Override
            public UzaiRespVo<Boolean> refundOrder(CashierWechatPayParam param) {
                return UzaiRespVo.fail("微信JSAPI退款申请失败");
            }

            @Override
            public UzaiRespVo<WxOrderQueryDto> queryRefundOrder(CashierWechatPayQueryParam param) {
                return UzaiRespVo.fail("微信JSAPI查询退款订单失败");
            }
        };
    }
}
